home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d14
/
atre12.arc
/
LF.ARC
/
LFWIN.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-27
|
4KB
|
160 lines
/*****************************
* Windows Support File for
* LF.C
******************************/
#include <windows.h>
#include "lfwin.h"
#include "lfdlg.h"
extern BOOL NEAR PASCAL main(HWND, LPSTR, LPSTR);
long FAR PASCAL WndProc (HWND, WORD, WORD, LONG);
BOOL FAR PASCAL AboutDlgProc (HWND, WORD, WORD, LONG);
HANDLE hInst;
FARPROC lpitAbout;
LPSTR szInFile;
LPSTR szOutFile;
#pragma argsused
int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)
{
static char szAppName[] = "LF";
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
if (!hPrevInstance)
{
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(hInstance, "lfico");
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = "MENU_RESOURCE";
wndclass.lpszClassName = szAppName;
RegisterClass(&wndclass);
}
else
{
MessageBox(NULL, "LF is already running!", "LF", MB_OK);
return FALSE;
}
hInst = hInstance;
hwnd = CreateWindow(szAppName, /* Class */
"LF", /* Title */
WS_OVERLAPPEDWINDOW, /* Style */
CW_USEDEFAULT, CW_USEDEFAULT, /* x, y */
240,180, /* xsize, ysize */
NULL, /* parent */
NULL, /* class menu */
hInstance, /* creator */
NULL); /* Params */
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
lpitAbout = MakeProcInstance((FARPROC)AboutDlgProc, hInst);
while (GetMessage(&msg, NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return /* msg.wParam */ FALSE;
}
long FAR PASCAL WndProc (HWND hwnd, WORD message, WORD wParam, LONG lParam)
{
HANDLE hMenu, hSysMenu;
static int cRun = 0;
switch (message)
{
case WM_COMMAND:
hMenu = GetMenu(hwnd);
hSysMenu = GetSystemMenu(hwnd, 0);
switch (wParam)
{
case IDM_EXIT:
DestroyWindow(hwnd);
break;
case IDM_RUN:
szOutFile = "lf.out";
szInFile = "lf.in";
EnableMenuItem(hMenu, IDM_EXIT, MF_GRAYED);
EnableMenuItem(hSysMenu, SC_CLOSE, MF_GRAYED);
EnableMenuItem(hMenu, IDM_RUN, MF_GRAYED);
DrawMenuBar(hwnd);
cRun ++;
SetWindowText(hwnd, (LPSTR) szInFile);
if (!main(hwnd, szInFile, szOutFile))
{
cRun --;
MessageBeep(0);
MessageBox(hwnd,"Could not run LF", "LF Error", MB_OK);
}
cRun --;
if (!cRun)
{
EnableMenuItem(hMenu, IDM_EXIT, MF_ENABLED);
EnableMenuItem(hSysMenu, SC_CLOSE, MF_ENABLED);
EnableMenuItem(hMenu, IDM_RUN, MF_ENABLED);
}
DrawMenuBar(hwnd);
break;
case IDM_ABOUT:
DialogBox(hInst,
MAKEINTRESOURCE(IDD_ABOUT),
hwnd,
lpitAbout);
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0L;
}
#pragma argsused
BOOL FAR PASCAL AboutDlgProc (HWND hdlg, WORD message, WORD wParam, LONG lParam)
{
switch (message)
{
case WM_COMMAND:
EndDialog(hdlg, TRUE);
return TRUE;
default:
return FALSE;
}
}